
AudioData = Class.extend({
    
    init: function (id) {
    	this.id = id;
        this.audios = [ '../audio/m9-shot.mp3',
                        '../audio/hv-uzi.wav',
                        '../audio/ak47-shot.mp3',
                        '../audio/reload.mp3',
                        '../audio/metalBleep.wav',
                        '../audio/enemyShot.mp3'
                        
                        
                        ];
        
    },
    
    preloadAudios: function (srcs, audios) {
    	var self = this;
        var audio;
        var remaining = srcs.length;
        for (var i = 0; i < srcs.length; i++) {
            
            audio = new Audio(srcs[i]);
            audio.oncanplaythrough  = function() {
                --remaining;
                
                if (remaining === 0){
                        var images = new GameImages(self.id);
                        images.loadImages(audios);
                }
            };
            audios.push(audio);
            
        }
    },

    loadAudio : function () {
        var audio = [];
        this.preloadAudios(this.audios, audio);
    }
    
    
});


